package review;

import java.util.Locale;

/**
 * 判断 字符串bde是不是字符串abdefg的子串
 */
public class 判断一个字符串是另一个字符串的子串 {

    /**
     * 使用循环遍历解决
     */
    public boolean judge(String baseStr,String searchStr) {
        if(baseStr.equals("") || searchStr.equals("")) {
            return false;
        }
        char[] base = baseStr.toCharArray();
        char[] search = searchStr.toCharArray();
        for (int i = 0; i < base.length; i++) {
            if(base[i] == search[0] && (i + search.length) <= base.length) {
                int j = 1;
                for (; j < search.length; j++) {
                    if(search[j] != base[i + j]) {
                        break;
                    }
                }
                if(j == search.length) {
                    return true;
                }
            }
        }
        return false;
    }
}
